import { View } from "../../../../mvc/core/View";
import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { BaseItem } from "../../common/BaseItem";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { FashionBoxUtil } from "../FashionBoxUtil";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { LoaderPriority } from "../../../../../com/gengine/resource/LoaderPriority";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
type int = number;
//class FashionJewelItem
    
    export  class FashionJewelItem extends View implements IToolTipItem
    {
        constructor()
        {
            super();
            this.initView();
            return;
        }

        public get attri(): int
        {
            return this._attri;
        }

        public get lv(): int
        {
            return this._lv;
        }

        /* internal  */initView(): void
        {
            this._bodySprite = new Object /* flash.display.Sprite */();
            this.addChild(this._bodySprite);
            var loc1=ResouceConst.getScaleBitmap(ImagesConst.equipment_boarder);
            this._bodySprite.addChild(loc1);
            this._bitmap = ObjCreate.createBitmap("", 9, 9, this);
            this._bitmap.width = 32;
            this._bitmap.height = 32;
            this._bItem = new BaseItem();
            this._bItem.isDragAble = false;
            this._bItem.isDropAble = false;
            this._bItem.isShowLock = true;
            this._bItem.setSize(32, 32);
            this._bItem.x = 9;
            this._bItem.y = 9;
            this._bodySprite.addChild(this._bItem);
            this._lvTx = ObjCreate.createGTextField("", 5, 26, 33, 20, this._bodySprite);
            this._lvTx.selectable = false;
            this._lvTx.mouseEnabled = false;
            this._lvTx.autoSize = flash.text.TextFieldAutoSize.CENTER;
            return;
        }

        public setSource(arg1: string): void
        {
            this._bItem.source = arg1;
            return;
        }

        public set selected(arg1: Boolean)
        {
            this._selected = arg1;
            if (this._selected) 
            {
                this._bodySprite.filters = [FilterConst.worldMapFilterEx];
            }
            else 
            {
                this._bodySprite.filters = [];
            }
            return;
        }

        public get selected(): Boolean
        {
            return this._selected;
        }

        public updateInfo(arg1: int, arg2: int): void
        {
            this._attri = arg1;
            this._lv = arg2;
            var loc1=FashionBoxUtil.getFashionJewelAttriPc(arg1, arg2);
            this._bItem.source = loc1;
            if (this._lastImageUrl) 
            {
                LoaderManager.instance.removeResourceEvent(this._lastImageUrl, this.onLoadCompleteHandler);
                this._lastImageUrl = "";
            }
            this._lastImageUrl = loc1;
            LoaderManager.instance.load(loc1, this.onLoadCompleteHandler, LoaderPriority.LevelC);
            this.setAmountText(arg2);
            return;
        }

        /* internal  */setAmountText(arg1: int): void
        {
            if (arg1 < 0) 
            {
                this._lvTx.text = "";
            }
            else 
            {
                this._lvTx.text = "Lv." + arg1;
            }
            return;
        }

        /* internal  */onLoadCompleteHandler(arg1: ImageInfo): void
        {
            this._lastImageUrl = "";
            this._bitmap.bitmapData = arg1.bitmapData;
            return;
        }

        public get toolTipData()
        {
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._toolTipData = arg1;
            return;
        }

        /* internal */ /* var */_selected: Boolean=false;

        /* internal */ /* var */_bodySprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_lvTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_attri: int;

        /* internal */ /* var */_lv: int;

        /* internal */ /* var */_bitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bItem: BaseItem;

        /* internal */ /* var */_lastImageUrl: string;

        protected /* var */_toolTipData;
    }
